home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / wininfo.zip / WW0530.EXE / WW0530T.TXT
Text File  |  1992-04-07  |  38KB  |  789 lines

  1. ======================================================================
  2.     Microsoft(R) Product Support Services Application Note (Text File)
  3.                WW0530: SMARTDrive and 32-Bit Disk Access
  4. ======================================================================
  5.                                                    Revision Date: 4/92
  6.                                                       No Disk Included
  7.  
  8. The following information applies to Microsoft Windows(TM) version 3.1.
  9.  
  10.  --------------------------------------------------------------------
  11. | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY    |
  12. | ACCOMPANY THIS DOCUMENT (collectively referred to as an            |
  13. | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      |
  14. | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO    |
  15. | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A     |
  16. | PARTICULAR PURPOSE. The user assumes the entire risk as to the     |
  17. | accuracy and the use of this Application Note. This Application    |
  18. | Note may be copied and distributed subject to the following        |
  19. | conditions: 1) All text must be copied without modification and    |
  20. | all pages must be included; 2) If software is included, all files  |
  21. | on the disk(s) must be copied without modification [the MS-DOS(R)  |
  22. | utility DISKCOPY is appropriate for this purpose]; 3) All          |
  23. | components of this Application Note must be distributed together;  |
  24. | and 4) This Application Note may not be distributed for profit.    |
  25. |                                                                    |
  26. |    Copyright 1992 Microsoft Corporation. All Rights Reserved.      |
  27. |         Microsoft and MS-DOS are registered trademarks             |
  28. |       and Windows is a trademark of Microsoft Corporation.         |
  29.  --------------------------------------------------------------------
  30.  
  31.  
  32.                              INTRODUCTION
  33.                              ============
  34.  
  35.  
  36. Microsoft Windows operating system version 3.1 has a number of
  37. enhancements over previous versions that improve both its usability
  38. and its performance. Foremost among these enhancements are Windows
  39. 3.1's improved features for accessing and utilizing the hard drive of
  40. your PC.
  41.  
  42.  
  43.                        SMARTDRIVE 4.0 DISK CACHE
  44.                        =========================
  45.  
  46.  
  47. Microsoft's first release of the Windows graphical environment
  48. included a disk caching program called SMARTDrive 3.03. SMARTDrive has
  49. been improved with each subsequent release of Windows and has been
  50. entirely redesigned in Windows version 3.1. SMARTDrive 4.0 in Windows
  51. 3.1 provides faster and more intelligent disk caching that takes
  52. better advantage of the revolutionary way that Windows and Windows-
  53. based applications use extended memory.
  54.  
  55. SMARTDrive 4.0 gives Windows 3.1:
  56.  
  57.     - Improved performance by speeding up hard disk and RAM access.
  58.     - Improved stability in 386 enhanced mode by double buffering data
  59.       when needed.
  60.  
  61. The remainder of this section compares the performance of SMARTDrive
  62. 4.0 to SMARTDrive 3.x and illustrates how SMARTDrive 4.0 works at a
  63. more technical level.
  64.  
  65.  
  66. WHAT IS SMARTDRIVE?
  67. ===================
  68.  
  69. SMARTDrive is a disk caching program that intercepts system calls to
  70. the hard disk to control read/write access to the disk. SMARTDrive
  71. intercepts any calls to the hard disk and loads the needed data into a
  72. cache it establishes in RAM. (Unless specified otherwise, SMARTDrive
  73. automatically determines a reasonable cache size based on the amount
  74. of free extended memory available when it initially loads; the maximum
  75. amount it will take is around 2 MB.) Subsequent calls to the hard disk
  76. are intercepted by SMARTDrive, which scans the cache for the requested
  77. data. If the data is already present in the cache, SMARTDrive can
  78. access it directly in RAM. If the data is not in the cache, SMARTDrive
  79. accesses the hard disk and loads the necessary data into the cache.
  80. The least recently used data residing in RAM is cached back to the
  81. hard disk to make room for the new data. By loading blocks of data
  82. from the hard disk into RAM, SMARTDrive helps decrease the number of
  83. calls to the hard disk. This can dramatically speed up applications
  84. that repeatedly access the hard disk for data because accessing the
  85. hard disk is considerably slower than accessing RAM. Essentially,
  86. SMARTDrive attempts to maintain information in RAM that an application
  87. needs at any given time from the hard disk.
  88.  
  89.  
  90. SMARTDRIVE 3.X
  91. ==============
  92.  
  93. To understand why SMARTDrive needed to be redesigned, letÆs look at
  94. how SMARTDrive 3.x works and examine some of the shortcomings of its
  95. design. First, SMARTDrive 3.x is a read-only track cache, which means
  96. that it caches on a track basis and for read operations only. This
  97. means that the internal data structures of the SMARTDrive program are
  98. tied to the logical geometry of the disk (that is, what MS-DOS sees).
  99. In the diagram below, you can see that SMARTDrive 3.x caches at the
  100. ROM BIOS INT13 level and uses the BIOS-specified disk geometry to
  101. decide the size of its caching element (that is, track size). INT13 is
  102. the most common method for interacting with hard disks (and has
  103. evolved into the industry standard). SMARTDrive under Windows 3.0 can
  104. be loaded into either extended memory or expanded memory.
  105.  
  106.  
  107.           Application
  108.        (Read/Write INT21)
  109.               |
  110. - - - - - - - - - - - - - - - - -
  111.               |                  
  112.            MS-DOS                
  113.        Call HD Driver
  114.               |                  
  115.           HD Driver              
  116.            INT 13
  117.               |                  
  118.               --------->  SMARTDrive 3.x
  119.                            Chains INT13
  120.               ---------<
  121.               |
  122.           ROM BIOS               
  123.               |                  
  124.                                  
  125.          Hard Drive
  126.  
  127.  
  128.  
  129.  
  130.  
  131. SMARTDRIVE 4.0
  132. ==============
  133.  
  134. SMARTDrive 4.0 is designed as a block-oriented disk cache. It hooks
  135. into the system at the MS-DOS device driver level rather than at the
  136. ROM BIOS INT13 level (as with SMARTDrive 3.x). Each block device
  137. driver on the MS-DOS device driver chain is ôfront-endedö by a
  138. SMARTDrive 4.0 module that provides the actual caching. This new
  139. design yields the following benefits:
  140.  
  141.     - It is independent of the INT13 interface.
  142.     - It is independent of disk geometry.
  143.  
  144.  
  145.  
  146.          Application             
  147.      (Read/Write INT21)
  148.               |
  149. - - - - - - - - - - - - - - -
  150.               |                  
  151.            MS-DOS                
  152.         Call HD Driver
  153.               |
  154.               --------->  SMARTDrive 4.0
  155.                            HOOKS Driver
  156.               ---------<
  157.               |
  158.            HD Driver              
  159.            INT 13
  160.               |  
  161.           ROM BIOS               
  162.               |                  
  163.                                  
  164.          Hard Drive
  165.  
  166.  
  167. Independent of INT13 Interface
  168. ------------------------------
  169.  
  170. Many device drivers do not use the INT13 (BIOS) interface (for
  171. example, Bernoulli drives, some hard cards, and many SCSI and WORM
  172. drives). This means that SMARTDrive 4.0 can cache these devices,
  173. whereas SMARTDrive 3.x cannot. SMARTDrive 4.0 can cache any disk
  174. controller that uses an MS-DOS block device driver.
  175.  
  176. Independent of Disk Geometry
  177. ----------------------------
  178.  
  179. Some disk managers and disk controllers use a disk geometry mapping
  180. scheme that causes the logical geometry to be different from the
  181. physical geometry (for example, many PS/2 systems, Ontrack's Disk
  182. Manager, and several disk controllers). The INT13-based disk caches
  183. are sensitive to this and often have problems. For example, some disk
  184. management software actually changes the ROM BIOS-specified disk
  185. geometry, which confuses INT13-based disk caches (including SMARTDrive
  186. 3.x).
  187.  
  188. There usually is an interface to determine the true geometry, but this
  189. requires detection of the specific disk manager driver and generally
  190. complicates the disk cache software. Often, logical tracks actually
  191. cross physical track boundaries, causing the track caches to incur
  192. performance penalties (intertrack seeks and rotational latencies, for
  193. example). To get around the ROM BIOS 1024-cylinder limitation, disk
  194. managers and controllers sometimes fold multiple tracks into one
  195. logical track. This results not only in problems with the physical
  196. track boundaries as noted above, buts forces track caches to have a
  197. very large track buffer as well. In some cases, this buffer can be as
  198. large as 31.5K and must reside in conventional memory. The design of
  199. SMARTDrive 4.0 eliminates this geometry mismatch problem.
  200.  
  201.  
  202. OTHER SMARTDRIVE 4.0 FEATURES
  203. =============================
  204.  
  205. Write-Behind Cache
  206. ------------------
  207.  
  208. SMARTDrive 4.0 is a write-behind cache, also known as lazy write. A
  209. write-behind cache adds significant performance improvements wherever
  210. files are being written to disk. For example, an application writes
  211. data to what it thinks is the hard disk. SMARTDrive takes this data
  212. and places it in the cache, rather than physically writing it to the
  213. disk. This write-behind data stays in the cache until one of the
  214. following occurs:
  215.  
  216. 1. The cache fills up. The oldest block in the cache is freed up, and
  217.    if it is write-behind data, physically written to the disk.
  218.  
  219. 2. The system goes idle. SMARTDrive writes the oldest write-behind
  220.    data block to the physical disk. As long as the system is idle,
  221.    SMARTDrive continues to write to the disk until all the write-
  222.    behind data is written. This write-behind data also comes from
  223.    Windows-based and MS-DOS-based applications that are idle.
  224.  
  225. 3. SMARTDrive detects that you have pressed CTRL+ALT+DEL. When you
  226.    restart by pressing CTRL+ALT+DEL, SMARTDrive writes all write-
  227.    behind data to the physical disk. This is a synchronous operation--
  228.    SMARTDrive does not give up control until all data is written.
  229.  
  230. 4. A block is older than five seconds. If a block is older than five
  231.    seconds, it is written to the physical disk.
  232.  
  233. Shrink Algorithm
  234. ----------------
  235.  
  236. Similar to SMARTDrive 3.x, SMARTDrive 4.0 implements a shrink
  237. algorithm that frees memory for Windows (that is, the cache set up by
  238. SMARTDrive is removed from memory). The difference is that SMARTDrive
  239. 4.0 watches for the Windows startup broadcast while SMARTDrive 3.x
  240. provides an IOCTL interface. The net effect is identical, but the
  241. SMARTDrive 4.0 code is much simpler. Upon exiting Windows, the process
  242. is reversed and the memory is reacquired by SMARTDrive 4.0.
  243.  
  244. Automatic Load High
  245. -------------------
  246.  
  247. When an upper memory block (UMB) provider (such as EMM386.EXE) is
  248. loaded, SMARTDrive 4.0 (SMARTDRV.EXE) automatically attempts to load
  249. itself high. Unlike the Windows 3.0 SMARTDrive, SMARTDrive 4.0 can
  250. only be loaded into extended memory.
  251.  
  252.  
  253. DOUBLE BUFFERING AND BUS MASTERING
  254. ==================================
  255.  
  256. The second major benefit of SMARTDrive 4.0 is the protection it
  257. provides through double buffering. Double buffering is a response to
  258. bus mastering, which is supported by certain (usually older) disk
  259. controllers. Bus mastering refers to a situation in which the hard
  260. disk controller takes over the bus to directly transfer data to or
  261. from system RAM, bypassing the CPU entirely. A problem occurs when
  262. Windows 3.x virtual machines and/or popular memory managers (such as
  263. EMM386.EXE and QEMM.SYS) are running in virtual 8086 mode. The read or
  264. write address that is passed to MS-DOS from the bus master controller
  265. is often not the same as the actual physical memory address. This can
  266. cause data to be read from the wrong location, or worse, can cause
  267. data to be written to the wrong RAM address, resulting in erratic
  268. system behavior and potential file corruption.
  269.  
  270. When paging is enabled on an 80386 or faster processor, it is possible
  271. for the physical address (the actual location of the memory) to be
  272. different from the virtual address (the address that programs are
  273. using to access memory). Paging is enabled by all device drivers that
  274. can provide load high capability and by Windows in 386 enhanced
  275. mode. For example, say SMARTDrive wants to write to an area of memory
  276. that has a virtual address in conventional memory, but a physical
  277. address in extended memory. When the hard drive controller takes over
  278. the bus and transfers data from the UMB to the disk, the controller
  279. does not use the CPU, so there is no address translation, resulting in
  280. the wrong data being written to disk. To avoid this problem, double
  281. buffering copies the data into a buffer in conventional memory and
  282. then passes the information to the hard disk controller. So, the
  283. virtual address always equals the physical address when using devices
  284. that only recognize conventional memory.
  285.  
  286. Installing Double Buffering
  287. ---------------------------
  288.  
  289. To install the SMARTDrive double-buffering feature, add the following
  290. line to your CONFIG.SYS file:
  291.  
  292.    device=c:\windows\smartdrv.exe /double_buffer
  293.  
  294. Including this line does not install the cache, only the double-
  295. buffering driver. The cache must be installed from the AUTOEXEC.BAT
  296. file or MS-DOS command line.
  297.  
  298. Most disk controllers do not need double buffering. These include all
  299. MFM, RLL, and IDE controllers as well as many ESDI and SCSI devices.
  300. The Setup program in Windows 3.1 will install the double buffer in the
  301. following cases:
  302.  
  303. 1. If the computer has an 80386 or faster processor
  304.  
  305. 2. If 32-Bit Disk Access was not installed in the SYSTEM.INI file (see
  306.    next section)
  307.  
  308. You should install the double buffer in these cases in the interest of
  309. added safety. Another new feature of SMARTDrive 4.0 that helps you
  310. determine if double buffering is necessary is the smartdrv command.
  311. Once your system is running with SMARTDrive loaded, type "smartdrv"
  312. (without the quotation marks) at the MS-DOS prompt and press ENTER.
  313. Information similar to the following is displayed:
  314.  
  315.      Microsoft SMARTDrive Disk Cache version 4.0
  316.      Copyright 1991, 1992 Microsoft Corp.
  317.      Cache size: 1,048,576 bytes
  318.      Cache size while running Windows: 1,048,576 bytes
  319.      
  320.                    Disk Caching Status
  321.      
  322.      
  323.      drive         read cache     write cache    buffering
  324.      ---------------------------------------------------
  325.      A:       yes            no           no
  326.      B:       yes           no            no
  327.      C:        yes            yes           yes
  328.      D:        yes            yes           ---
  329.      
  330.      For help, type "Smartdrv /?".
  331.  
  332. Note the column labeled "buffering." For each drive that is being
  333. cached, one of three values is displayed--"yes," indicating that
  334. double buffering is needed; "no," indicating that double buffering is
  335. not needed; or "---," indicating that SMARTDrive has not yet
  336. determined the necessity of double buffering. If the buffering column
  337. displays a "no" for each drive, the double buffer driver is
  338. unnecessary, and you can safely remove it from your CONFIG.SYS file.
  339.  
  340. Setting Up SMARTDrive 4.0
  341. -------------------------
  342.  
  343. The Setup program in Microsoft Windows 3.1 automatically installs
  344. SMARTDrive (SMARTDRV.EXE) in the first line of your AUTOEXEC.BAT file.
  345. In general, you should let the Setup program configure SMARTDriveÆs
  346. cache size for you. However, please note it is critical that
  347. SMARTDRV.EXE load after any block devices that reside on your system,
  348. such as:
  349.  
  350.     - Hard disk partitioning software (for example, DMDRVR.BIN and
  351.       SSTOR.SYS)
  352.     - Hard disk drivers (for example, SCSI drives, hard cards, and
  353.       Bernoulli drives)
  354.     - Data encryption software (for example, Stacker and DoubleDisk)
  355.    
  356. The configuration of SMARTDRV.EXE is controlled by command-line
  357. parameters. Most configuration options can be modified without
  358. restarting; however, without the Windows Resource Kit utility
  359. SMARTDrive Monitor (SMARTMON.EXE), the configuration cannot be altered
  360. while running Windows. Also note that SMARTDrive:
  361.  
  362.     - Needs a minimum cache size of 16K.
  363.     - Creates a cache size of 16K by default if you supply an invalid
  364.       cache size.
  365.     - Gives you benefits up to a cache size of 2 MB, whereupon the
  366.       benefits typically plateau.
  367.  
  368.  
  369.                           32-BIT DISK ACCESS
  370.                           ==================
  371.  
  372.  
  373. Another new feature of Windows 3.1 is its use of 32-Bit Disk Access.
  374. 32-Bit Disk Access is not a program but rather a term used to refer to
  375. a system of Windows components working together. The main purpose of
  376. these components is to allow Windows to interact directly with the
  377. hard disk, bypassing the BIOS, which is normally used for
  378. communicating with the hard disk. Under 386 enhanced mode Windows,
  379. where 32-Bit Disk Access is supported, you get the following benefits:
  380.  
  381.     - Faster hard disk access
  382.     - Ability to run more MS-DOS-based applications
  383.     - Faster overall system response, even when running MS-DOS-based
  384.       applications in the background
  385.     - More powerful off-the-shelf disk utilities to choose from, since
  386.       independent software vendors (ISVs) are writing programs that
  387.       take advantage of this new set of services
  388.  
  389.  
  390. WHAT IS 32-BIT DISK ACCESS?
  391. ===========================
  392.  
  393.     - A SYSTEM OF WINDOWS COMPONENTS. Some of these components are
  394.       called 32-Bit Disk Access devices, but they are useless without
  395.       the rest of the components to support them. Each of these
  396.       components is discussed below.
  397.    
  398.     - A REPLACEMENT FOR THE HARD DISK BIOS. 32-Bit Disk Access serves
  399.       as a device driver that interacts with the hard disk controller.
  400.       32-Bit Disk Access watches for INT13H calls and handles them if
  401.       they are for the disk it represents; otherwise, it passes the
  402.       calls on to the BIOS in the usual way, as if 32-Bit Disk Access
  403.       were not available.
  404.    
  405.     - AN EXACT MATCH FOR THE HARD DISK CONTROLLER (NOT THE SPECIFIC
  406.       HARD DISK). There are some standards for hardware communication
  407.       that work on many different controllers. The most widely adopted
  408.       standard is that introduced by Western Digital in its 1003
  409.       controllers. This is the standard supported by Windows 3.1 and
  410.       more than 90 percent of hard disk controllers, with the
  411.       exception of ESDI and SCSI controllers.
  412.    
  413.     - AN OPEN STANDARD FOR CERTAIN CONTROLLERS. 32-Bit Disk Access is
  414.       an open standard that is being promoted to all manufacturers of
  415.       hard disk controllers. This means that every manufacturer has
  416.       the opportunity to write a device driver that supports 32-Bit
  417.       Disk Access functionality for its hardware. Many hardware
  418.       manufacturers are writing 32-Bit Disk Access device drivers that
  419.       will be available at the time Windows 3.1 ships or shortly
  420.       thereafter.
  421.    
  422.     - AN OPTION, NOT A SYSTEM REQUIREMENT. Without the 32-Bit Disk
  423.       Access device driver installed, you lose the hardware-access
  424.       benefits provided by 32-Bit Disk Access, but your system is
  425.       otherwise unaffected. Windows 3.1 without 32-Bit Disk Access has
  426.       the same disk access capabilities of Windows 3.0.
  427.  
  428.  
  429. DISK ACCESS UNDER MS-DOS
  430. ========================
  431.  
  432. The 32-Bit Disk Access feature bypasses the system BIOS to more
  433. directly control hard disk access. It acts, in a sense, as the hard
  434. disk controller. Before discussing how disk access has changed under
  435. Windows 3.1, letÆs look at how MS-DOS handles calls to the hard disk.
  436.  
  437. In the MS-DOS-based PC, when an application wants to read from the
  438. disk, it tracks the following sequence:
  439.  
  440.                                          H/W               
  441.          INT21H          INT13H          I/O
  442.         ------>           ----->        ----->              
  443.  -----           ------           ----          ----------     -----
  444. | APP |         |MS-DOS|         |BIOS|        |Controller| ->|Drive|
  445.  -----           ------           ----          ----------     -----
  446.  
  447.  
  448. 1. The application makes an INT21H call to MS-DOS.
  449.  
  450. 2. MS-DOS locates the requested part of the file on the hard disk.
  451.  
  452. 3. MS-DOS issues an INT13H call to talk to the hard disk BIOS. The
  453.    BIOS contains a program to control each device in the system.
  454.  
  455. 4. The BIOS driver talks directly to the hard disk controller. Each
  456.    hard disk controller requires its own BIOS driver, but these BIOS
  457.    drivers are usually not specific to the hard disk itself, but
  458.    rather to the controller board (or adapter) that connects the hard
  459.    disk to the rest of the system.
  460.  
  461. This system works well, because MS-DOS is able to identify the files
  462. and directories and keep track of their locations, regardless of the
  463. type of hard disk MS-DOS is accessing. But, on the other hand, the
  464. system BIOS is wholly linked to the hard disk, which provides disk
  465. independence for the applications but does not allow the BIOS to
  466. differentiate between a call from MS-DOS or a program such as
  467. SMARTDrive.
  468.  
  469. But remember that not all disk device drivers reside in ROM. If you
  470. purchase an off-the-shelf disk drive and install it, your computerÆs
  471. ROM BIOS may not know how to communicate with it. If this is the case,
  472. you must install a device driver that is specific to your new hard
  473. disk. This additional device driver is usually installed in your
  474. CONFIG.SYS file when you install the software that comes with your
  475. hard disk. With some devices, such as a CD-ROM drive, a device driver
  476. that provides the BIOS interface and INT13H interface to the CD-ROM
  477. drive appears in your AUTOEXEC.BAT file. This type of device driver
  478. traps INT13H calls to the hard disk and makes sure the calls are
  479. understood by the hard disk. Usually, the device driver handles any
  480. attempts to access the hard disk; the calls never get passed on to the
  481. real ROM BIOS. If the call is not for the device that the device
  482. driver represents, then the INT13H call is passed on to the BIOS,
  483. where it is handled in the usual way. 32-Bit Disk Access represents a
  484. way for Windows to provide a BIOS that better suits customers' device
  485. support needs.
  486.  
  487.  
  488. 32-BIT DISK ACCESS SPEEDS UP DISK ACCESS
  489. ========================================
  490.  
  491. On many machines, the resident hard disk BIOS is slow and inefficient.
  492. Since 32-Bit Disk Access is specific to devices, it is often more
  493. efficient, leading to very impressive performance increases. 32-Bit
  494. Disk Access also allows Windows 3.1 to handle BIOS requests in
  495. protected mode, rather than in real mode, which may also speed up disk
  496. access. The following diagram charts the flow of calls under Windows
  497. in standard mode:
  498.  
  499.                                          H/W               
  500.          INT21H          INT13H          I/O
  501.         ------>           ----->        ----->              
  502.  -----           ------           ----          ----------     -----
  503. | APP |         |MS-DOS|         |BIOS|        |Controller| ->|Drive|
  504.  -----           ------           ----          ----------     -----
  505.  
  506.  
  507. Under 386 enhanced mode Windows, the flow of calls is more
  508. complicated:
  509.  
  510.  
  511.          ------------------------------------------------- 
  512.         |         Enhanced Mode Virtual Devices           |
  513.          -------------------------------------------------
  514. Protected   / \          /    \                                  
  515.   Mode     /   \        /      \
  516. ----------/-----\------/--------\-----------------------------------
  517. Virtual  /       \    /          \                         
  518.  Mode   /         \  /            \
  519.    -----   INT21H  ------   INT13H ----    H/W   ----------     -----
  520.   | APP |         |MS-DOS|        |BIOS|   I/O  |Controller|-->|Drive|
  521.    -----           ------          ----  ----->  ----------     -----
  522.  
  523. Windows 3.1 and Windows applications run in protected mode. Windows
  524. has to switch back into real mode (or virtual 8086 mode) to run older
  525. code (for MS-DOS and the BIOS calls, for example). Switching modes is
  526. very time consuming. For example, when a non-Windows application
  527. running under 386 enhanced mode tries to read from a file, the
  528. following occurs:
  529.  
  530.    Windows starts out in virtual mode running the application. Windows
  531.    makes an INT21H call to read from the file. 386 enhanced mode traps
  532.    this interrupt and switches to protected mode, where a number of
  533.    virtual device drivers look at the call and try to qualify it. If
  534.    none of the device drivers intercepts the call, the call is
  535.    accepted and is subsequently handed off to MS-DOS.
  536.    
  537.    Windows then switches back to virtual mode to let MS-DOS handle the
  538.    call. MS-DOS reads a particular location on the disk and then
  539.    generates an INT13H call to talk to the BIOS. Windows in 386
  540.    enhanced mode then traps the call again and switches to protected
  541.    mode to perform certain tasks, hands the call back to the real
  542.    BIOS, and switches back to virtual mode.
  543.    
  544.    The BIOS handles the call and accesses the hard disk controller to
  545.    set the physical read in motion. Once the BIOS reads the call,
  546.    Windows goes back to protected mode to perform more tasks and then
  547.    returns to virtual mode to let MS-DOS see the returned call.
  548.    Windows returns the INT21H call, switches to protected mode to
  549.    perform yet more tasks, and then finally switches back to virtual
  550.    mode to communicate with the application that issued the call to
  551.    begin with.
  552.  
  553. All this mode switching takes time but is necessary due to the nature
  554. of the 80386 processor, MS-DOS, and the PC BIOS. With a 32-Bit Disk
  555. Access device installed, Windows can start trapping INT13H calls and
  556. handling them entirely in protected mode. With 32-Bit Disk Access, the
  557. call diagram now looks like this:
  558.  
  559.    ----------------------------     H/W     ----------     -----
  560.   |Enhanced Mode   |32-Bit Disk|    I/O    |Controller| ->|Drive|
  561.   |Virtual Devices |     Access|  ----->    ----------     -----
  562.    -----------------------------
  563. Protected    /   \           /                        
  564.   Mode      /     \         /
  565. -----------/-------\-  ----/---------------------------------------
  566. Virtual   /         \     /
  567.  Mode    /           \   /
  568.       -----   INT21H  ------  INT13H   ----
  569.      | APP |         |MS-DOS|         |BIOS|
  570.       -----           ------           ----
  571.  
  572.  
  573. With 32-Bit Disk Access, Windows no longer has to go through two mode
  574. transitions--one mode to get to the BIOS and the other mode to get
  575. back. Only two mode switches per INT13H call, rather than four, are
  576. now being performed.
  577.  
  578.  
  579. 32-BIT DISK ACCESS SUPPORT FOR NON-WINDOWS APPLICATIONS
  580. =======================================================
  581.  
  582. Sometimes Windows shows an adequate amount of free memory and large
  583. Windows-based applications run just fine, yet an "Out of Memory"
  584. message is generated when a non-Windows application is started. Also,
  585. in spite of the available memory, Windows-based applications may slow
  586. down and constantly access the hard disk after a non-Windows
  587. application is started.
  588.  
  589. These discrepancies occur because of the difference between virtual
  590. memory (which is often large) and physical memory (RAM, which is
  591. usually limited). On a given machine, virtual memory might be four
  592. times the size of RAM. But, while virtual memory works well for
  593. Windows-based applications, it doesnÆt always meet all the systemÆs
  594. memory needs for MS-DOS-based applications.
  595.  
  596. Because each non-Windows application runs in its own virtual machine,
  597. each application takes up 640K or more of virtual memory. When the
  598. virtual machine is actually running, all of the program code needs to
  599. occupy RAM. Parts of the non-Windows application cannot be paged out
  600. while keeping other parts in RAM, as is the case with Windows-based
  601. applications. The virtual machine in which the non-Windows application
  602. runs must be treated as a single block. This is true even if the
  603. application is currently inactive in the background.
  604.  
  605. With Windows-based applications, most of the program remains resident
  606. on the hard disk, while only the parts that are actually being used
  607. are loaded in RAM. Problems occur when Windows tries to do this with
  608. non-Windows-based applications.
  609.  
  610. If a part of the application that is not currently being used--a data
  611. buffer, for example--is paged out, it can always be read back in
  612. whenever the application needs to access it. However, if the
  613. application makes a call to MS-DOS to read some data from the disk
  614. into a buffer, MS-DOS starts handling the call by making a call to
  615. INT13H to talk to the BIOS, which in turn talks to the hard disk
  616. controller, resulting in the transfer of data into the buffer. So when
  617. the application needs to transfer the page into the buffer, which is
  618. currently out on disk, the application tries to call MS-DOS to read
  619. the page.
  620.  
  621. Because MS-DOS is already occupied, the application canÆt call MS-DOS;
  622. and MS-DOS is not reentrant, so the second call from the application
  623. fails. Nor can the application have the page read by calling the BIOS,
  624. because the BIOS is also in the middle of a call, so it canÆt be
  625. reentered either. This situation results in a type of deadlock: the
  626. application canÆt let the current call finish until the page is put in
  627. the buffer, but the page cannot be placed in the buffer until the
  628. current call finishes.
  629.  
  630. The only way to ensure that this deadlock situation does not occur is
  631. to make sure that Windows never has to page anything in while the
  632. application is in the middle of an MS-DOS or BIOS call. Because
  633. Windows cannot predict ahead of time what the application will try to
  634. access, the only way to be 100-percent safe from deadlocking is to
  635. make sure everything the application might try to access is already in
  636. RAM (that is, never paged out to disk). In other words, all 640K-plus
  637. of the virtual machine in which the non-Windows application is running
  638. has to remain resident in RAM, thereby using up a lot of physical
  639. memory. Running several non-Windows-based applications at once uses
  640. large amounts of RAM, so you may soon end up with only a small amount
  641. of free RAM left for everything else youÆre trying to do, such as run
  642. Windows-based applications. When you check the Program Manager About
  643. dialog box (from the Help menu), it shows that you have plenty of
  644. memory--virtual memory--and you do. But if you try to start another
  645. non-Windows application, which requires yet another 640K of RAM, the
  646. application won't start. So, Windows starts running sluggishly and/or
  647. may generate the "Out of Memory" message.
  648.  
  649. So how does 32-Bit Disk Access help? Windows 3.0 offered a contiguous
  650. paging file (which is created with Swapfile) for any pages using the
  651. INT13H BIOS calls. Windows 3.1 handles the same task by making calls
  652. to the 32-Bit Disk Access system. Unlike MS-DOS or the BIOS, the 32-
  653. Bit Disk Access system can queue up multiple requests and is
  654. completely reentrant. Windows no longer needs to rely on MS-DOS or the
  655. BIOS; so regardless of what the application is doing, Windows can
  656. always page calls in from the hard disk. Free from a potential
  657. deadlock situation, Windows 3.1 can now make the virtual machines that
  658. are running completely pageable. Non-Windows-based applications no
  659. longer need to take up so much RAM, since they can now use virtual
  660. memory the way Windows-based applications do. When Windows needs some
  661. RAM space, it can now page out pieces of these virtual machines.
  662.  
  663. With Windows 3.1 and 32-Bit Disk Access, you can run multiple non-
  664. Windows-based applications and Windows-based applications without
  665. generating an "Out of Memory" message. When the About box tells you
  666. that you have 14 MB of memory, you can actually use all 14 MB for
  667. running your applications, whether they are Windows or non-Windows.
  668.  
  669. Improved Performance for Non-Windows Applications Under Windows
  670. ---------------------------------------------------------------
  671.  
  672. In the previous example, we saw how 32-Bit Disk Access in Windows can
  673. page non-Windows-based applications to free up enough RAM for those
  674. applications when they need to use it. The 32-Bit Disk Access feature
  675. also improves Windows performance all around, making the system run
  676. much more quickly.
  677.  
  678. Switching between non-Windows-based applications by pressing ALT+TAB
  679. is faster with 32-Bit Disk Access. Without 32-Bit Disk Access, a non-
  680. Windows application can only be swapped out to disk if it is
  681. configured to not run in the background. This means when you press
  682. ALT+TAB to switch to such an application, Windows has to read the
  683. entire program into RAM, causing the task switching to take a long
  684. time. When Windows is paging using 32-Bit Disk Access, Windows can
  685. load in just the small amount of information that the application is
  686. actually using, so task switching becomes almost instant. And, since
  687. only a small part of the application needs to be in RAM at one time,
  688. Windows may not have to access the hard disk at all.
  689.  
  690.  
  691. THE COMPONENTS OF THE 32-BIT DISK ACCESS SYSTEM
  692. ===============================================
  693.  
  694. The 32-Bit Disk Access system is composed of the following 386
  695. enhanced mode virtual devices:
  696.  
  697.     - WDCTRL, which is the 32-Bit Disk Access device that talks to
  698.       standard Western Digital 1003 or ST506 hard disk controllers
  699.       (about 90 percent of the installed base). WDCTRL is only
  700.       installed if Setup detects a compatible hard disk controller.
  701.    
  702.     - BlockDev, which coordinates calling block I/O services between
  703.       devices and the 32-Bit Disk Access devices that provide those
  704.       services for specific hard disk controllers. BlockDev is always
  705.       installed.
  706.    
  707.     - PageFile, which handles the virtual memory paging file and calls
  708.       through BlockDev if any 32-Bit Disk Access devices are
  709.       available. PageFile is always installed.
  710.    
  711.     - INT13, which traps and emulates INT13H BIOS calls by calling
  712.       BlockDev. INT13 is only installed if at least one 32-Bit
  713.       Disk Access device is present.
  714.    
  715. Because WDCTRL is the only 32-Bit Disk Access device included in the
  716. Windows box, the standard Windows components only support 32-Bit Disk
  717. Access for Western Digital-standard controllers. When you run Setup,
  718. it automatically detects these controllers and adds the following
  719. lines to the [386Enh] section of your SYSTEM.INI file:
  720.      
  721.      device=*int13
  722.      device=*wdctrl
  723.      
  724. If you want to disable 32-Bit Disk Access, start the Control Panel and
  725. choose the 386 Enhanced icon, or comment the lines out of your system
  726. by placing a semicolon (;) at the beginning of both lines. You do not
  727. need to delete any files from your hard disk, as the 32-Bit Disk
  728. Access devices are contained within the file WIN386.EXE.
  729.  
  730.  
  731. 32-BIT DISK ACCESS AND HARD DISK PROTECTION
  732. ===========================================
  733.  
  734. Microsoft identified machines where the use of WDCTRL can stop the
  735. system. Usually, this is caused by hard disk controllers that appear
  736. to be Western Digital 1003 compatible but are really not. WDCTRL has
  737. been put though rigorous testing to make sure it is as safe as
  738. possible, and is designed with a built-in safety measure--every time
  739. it starts, it performs elaborate tests to make sure it can communicate
  740. in the same language as the hard disk controller before it attempts to
  741. read and write data. WDCTRL starts testing by taking a peripheral look
  742. at some data on the hard disk for tell-tale traces of a Western
  743. Digital 1003-compatible controller. If the controller passes that
  744. test, WDCTRL then starts calling up larger pieces of data to try to
  745. elicit the correct response. Finally, after much redundant checking,
  746. WDCTRL tries actually reading data from the disk. If it is able to
  747. read data, WDCTRL then tries to write data and read it back. Only
  748. after the read/write test is passed does WDCTRL continue and start
  749. Windows, reassured that it will not cause any catastrophic errors on
  750. the hard disk.
  751.  
  752. However, there are still a few exceptions. There are drives that
  753. appear to be WD1003 compatible but are not, and which cannot be
  754. detected by WDCTRL. In addition, there can be problems even with
  755. compatible controllers on some portable computers, specifically those
  756. that power down the hard disk to conserve power without telling the
  757. running software. If the disk is powered down and then back up while
  758. it is being tracked by WDCTRL, the tracking information will be
  759. incorrect, and serious damage can result. For these reasons, 32-Bit
  760. Disk Access is not turned on by default. When you install Windows, 32-
  761. Bit Disk Access is disabled until you make the decision to enable it
  762. through Control Panel. Only original equipment manufacturers (OEMs)
  763. who preinstall Windows 3.1 on a 100-percent-compatible system can turn
  764. 32-Bit Disk Access on before the user receives the system without
  765. jeopardizing the userÆs hard disk.
  766.  
  767. When something does go wrong, WDCTRL may do different things,
  768. depending on where it is in its verification code. The initial tests
  769. have reported WDCTRL as extremely safe. The controllers that WDCTRL
  770. fails with are considered incompatible with 32-Bit Disk Access, so
  771. WDCTRL simply does not load when it senses these unsupported
  772. controllers. This procedure is invisible to the user; he or she just
  773. wonÆt receive the benefits of 32-Bit Disk Access. If WDCTRL fails a
  774. test after it is installed, Windows displays an error message that
  775. warns that something is wrong, most likely that the hard disk might
  776. have been damaged, and advises to restart the machine (so that WDCTRL
  777. does not load, and 32-Bit Disk Access is disabled).
  778.  
  779.  
  780. THIRD-PARTY 32-BIT DISK ACCESS DEVICES
  781. ======================================
  782.  
  783. Windows 3.1 ships with only one 32-Bit Disk Access device--WDCTRL.
  784. However, Microsoft is working with most of the major hardware and
  785. software vendors to help them design 32-Bit Disk Access devices for
  786. their products. Concerns regarding distribution and quality of testing
  787. for these third-party devices are currently being addressed.
  788.  
  789.